package com.wen.common;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class R {

    private Boolean flag;
    private String message;
    private Map<String,Object> data = new HashMap<>();

    private R(){

    }

    public static R ok(){
        R r = new R();
        r.setFlag(true);
        r.setMessage("成功");
        return r;
    }

    public static R error(){
        R r = new R();
        r.setFlag(false);
        r.setMessage("失败");
        return r;
    }

    public R data(String key,Object value){
        this.getData().put(key,value);
        return this;
    }

    public R flag(Boolean flag){
        this.setFlag(flag);
        return this;
    }

    public R message(String message){
        this.setMessage(message);
        return this;
    }

}
